package com.gjy.spring.s11.jdk;

import java.lang.reflect.Method;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-12-20 16:40:27
 */
public class MethodInvokeTest {

    public static void main(String[] args) throws Exception {
        Method method = MethodInvokeTest.class.getDeclaredMethod("foo", int.class);
        for (int i = 0; i < 17; i++) {
            show(i, method);
            method.invoke(null, i);
        }
    }

    // 反射方法调用时，底层 MethodAccessor 的实现
    private static void show(int i, Method method) throws Exception {
        System.out.println(i + ":" + method.getClass());
    }

    public static void foo(int i) {
        System.out.println("foo " + i);
    }
}
